package com.chennan.book.domain.model;

import lombok.Data;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

/**
 * @author chennan
 * @create 2023-08
 */
@Data
public class ExcelFeishuiModel implements Serializable {
    private UUID id;
    private String adm_div_code;
    private String adm_div_name;
    private String chg_agen_code;
    private String chg_agen_name;
    private String pay_code;
    private String payer_name;
    private String amt;
    private String pay_time;
    private String pay_info;

    private String insertSql = "Insert into FA_PAYHISTORY_CODE " +
            "(id,adm_div_code,adm_div_name,chg_agen_code,chg_agen_name,pay_code,payer_name,amt,pay_time,pay_info)" +
            "values(";
    public String generateSql() throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        StringBuilder sb = new StringBuilder();
        sb.append(insertSql);
        sb.append("'"+id.toString()+"',");
        sb.append("'"+adm_div_code+"',");
        sb.append("'"+adm_div_name+"',");
        sb.append("'"+chg_agen_code+"',");
        sb.append("'"+chg_agen_name+"',");
        sb.append("'"+pay_code+"',");
        sb.append("'"+payer_name+"',");
        sb.append(amt+",");
        Date parse = format1.parse(pay_time);
        String format2 = format.format(parse);
        sb.append("TIMESTAMP '"+format2+"',");
        sb.append("'"+pay_info+"');\n");
        return sb.toString();
    }
}
